﻿using Engine;
using Engine.Graphics;
using System;

namespace Game
{
    public class 矿模型 : Block
    {
        public const int Index = 301;
        public Texture2D m_texture;
        public BlockMesh m_standaloneBlockMesh = new BlockMesh();

        public override void Initialize()
        {

          
            Model model = ContentManager.Get<Model>("Models/Amethyst", null);
            Matrix boneAbsoluteTransform = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Amethyst", true).ParentBone);
            
           
            BlockMesh blockMesh = new BlockMesh();
            blockMesh.AppendModelMeshPart(model.FindMesh("Amethyst", true).MeshParts[0], boneAbsoluteTransform * Matrix.CreateTranslation(0f, 0f, 0f), false, false, false, false, Color.White);
            
            this.m_standaloneBlockMesh.AppendBlockMesh(blockMesh);
            base.Initialize();
            InHandScale = (float)0.35;
            FirstPersonScale = (float)0.4;
            FirstPersonOffset = new Vector3((float)0.5, (float)-0.5, (float)-0.5);
            base.Initialize();
            

        }

        public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z)
        {
            generator.GenerateCubeVertices(this, value, x, y, z, Color.White, geometry.GetGeometry(this.m_texture).OpaqueSubsetsByFace);
        }

        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {

            BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneBlockMesh, color, 2f * size, ref matrix, environmentData);
        }
        public override int GetTextureSlotCount(int value)
        {
            return 1;
        }
    }
}
